package neusoft.yuejian_11.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.squareup.picasso.Picasso;

import java.util.List;

import neusoft.yuejian_11.base.BaseListAdapter;
import neusoft.yuejian_11.bean.CommentBean;
import neusoft.yuejian_11.R;
import neusoft.yuejian_11.viewHolder.CommentViewHolder;

import static neusoft.yuejian_11.interF.Const.BASE_URI;

/**
 * Created by NEUSOFT on 2017/10/15.
 */

public class CommentAdapter extends BaseListAdapter {
    public CommentAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    protected RecyclerView.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater layoutInflater, int viewType) {
        View itemView=layoutInflater.inflate(R.layout.item_comment,parent,false);
        CommentViewHolder holder=new CommentViewHolder(itemView);
        return holder;
    }

    @Override
    protected void onBindVH(RecyclerView.ViewHolder holder, List data, int position) {
        CommentViewHolder commentViewHolder=(CommentViewHolder) holder;
        final CommentBean commentBean = (CommentBean)data.get(position);
        final String commentinfo =commentBean.getCo_info();
        String commentpeople=commentBean.getU_name();
        String commenttime=commentBean.getCo_createtime();
        final int postId = commentBean.getP_id();
        String pic = BASE_URI+"photo/"+commentBean.getU_pic();
        Picasso.with(context)
                .load(pic)
                .placeholder(R.drawable.ic_cook_holder)
                .error(R.drawable.ic_cook_holder_error)
                .into(CommentViewHolder.imageView);
        commentViewHolder.commentinfoView.setText(commentinfo);
        commentViewHolder.commentpeopleView.setText(commentpeople);
        commentViewHolder.commenttimeView.setText(commenttime);
    }

}
